<?php

namespace app\common\model;

use think\Model;

class News extends Model
{
    // 表名
    protected $name = 'news';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    // 追加属性
    protected $append = [
        'lx_text',
        'hot_text',
        'titlebold_text',
        'titlecolor_text',
        'flag_text',
        'qy_text'
    ];



    public function getLxList()
    {
        return ['湛江房产' => __('Lx 湛江房产'),'全国房产' => __('Lx 全国房产'),'港城生活' => __('Lx 港城生活'),'看房日记' => __('Lx 看房日记'),'楼市快讯' => __('Lx 楼市快讯'),'销售动态' => __('Lx 销售动态'),'房产数据' => __('Lx 房产数据'),'城市规划' => __('Lx 城市规划'),'购房指南' => __('Lx 购房指南'),'法律法规' => __('Lx 法律法规'),'精英访谈' => __('Lx 精英访谈'),'购房萌萌哒' => __('Lx 购房萌萌哒'),'品牌直通车' => __('Lx 品牌直通车'),'碧桂园' => __('Lx 碧桂园'),'行业招聘' => __('Lx 行业招聘')];
    }

    public function getTypeList()
    {
        return ['0' => __('Type 0'),'1' => __('Type 1'),'2' => __('Type 2'),'3' => __('Type 3')];
    }

    public function getDisplayModeList()
    {
        return ['0' => __('Display_mode 0'),'1' => __('Display_mode 1'),'2' => __('Display_mode 2')];
    }

    public function getWeighList()
    {
        return ['0' => 0,'1' => 1,'2' => 2,'3' => 3,'4' => 4,'5' => 5];
    }

    public function getHotList()
    {
        return ['0' => __('Hot 0'),'1' => __('Hot 1')];
    }

    public function getTitleboldList()
    {
        return ['0' => __('Titlebold 0'),'1' => __('Titlebold 1')];
    }

    public function getTitlecolorList()
    {
        return ['""' => __('Titlecolor ""'),'ff0000' => __('Titlecolor ff0000'),'0000ff' => __('Titlecolor 0000ff'),'00CD00' => __('Titlecolor 00cd00'),'8A2BE2' => __('Titlecolor 8a2be2')];
    }

    public function getFlagList()
    {
        return ['0' => __('Flag 0'),'1' => __('Flag 1')];
    }

    public function getAttributeList()
    {
        return ['0' => __('Attribute 0'),'1' => __('Attribute 1'),'2' => __('Attribute 2')];
    }

    public function getQyList()
    {
        return ['0' => __('Qy 0'),'1' => __('Qy 1'),'2' => __('Qy 2'),'3' => __('Qy 3'),'4' => __('Qy 4'),'5' => __('Qy 5')];
    }


    public function getLxTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['lx']) ? $data['lx'] : '');
        $list = $this->getLxList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getDisplayModeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['display_mode']) ? $data['display_mode'] : '');
        $list = $this->getDisplayModeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getWeighTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['weigh']) ? $data['weigh'] : '');
        $list = $this->getWeighList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getHotTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['hot']) ? $data['hot'] : '');
        $list = $this->getHotList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTitleboldTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['titlebold']) ? $data['titlebold'] : '');
        $list = $this->getTitleboldList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getTitlecolorTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['titleColor']) ? $data['titleColor'] : '');
        $list = $this->getTitlecolorList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getFlagTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['flag']) ? $data['flag'] : '');
        $list = $this->getFlagList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getAttributeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['attribute']) ? $data['attribute'] : '');
        $list = $this->getAttribute();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getQyTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['qy']) ? $data['qy'] : '');
        $list = $this->getQyList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function admin()
    {
        return $this->belongsTo('\app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
